package modelLayer;
import java.util.ArrayList;
import java.util.Iterator;

/**
 * DVD clss defines a DVD.
 * @author group 6 - Stefan Patatu, Stan Cosmin Madalin, Monika Vyšniauskaitė, Larowski Michal, Njogu Alex, Cristian Moldovan
 */
public class DVD {
    private String title;
    private long barcode;
    private String artist;
    private String publicationDate;
    private ArrayList<Copy> copies;

    /**
     * Create a DVD object.
     * @param title The title of a dvd.
     * @param barcode The barcode of a dvd.
     * @param artist The artist of the dvd.
     * @param publicationDate The publication date of a dvd.
     */
    public DVD(String title, long barcode, String artist, String publicationDate) {
        copies = new ArrayList<>();
        this.title = title;
        this.barcode = barcode;
        this.artist = artist;
        this.publicationDate = publicationDate;
    }
    
    /**
     * Get the barcode of a dvd.
     */
    public long getBarcode() {
        return barcode;
    }
    
    /**
     * Set a given title to a dvd.
     * @param title The title of a dvd
     */
    public void setTitle(String title) {
        this.title = title;
    }
    public String getTitle() {
        return title;
    }
    
    /**
     * Set a given artist to a dvd.
     * @param artist The artist of a dvd.
     */
    public void setArtist(String artist) {
        this.artist = artist;
    }
    public String getArtist() {
        return artist;
    }
    
    /**
     * Set a given publication date to a dvd
     * @param publicationDate The publication date of a dvd
     */
    public void setPublicationDate(String publicationDate) {
        this.publicationDate = publicationDate;
    }
    public String getPublicationDate() {
        return publicationDate;
    }
    
    /**
     * Add a copy of a dvd
     * @param serialNumber The serialNumber of a copy of a dvd
     * @param purchase price The purchase price of a copy of a dvd
     * @param purchaseDate The purchase date of a copy of a dvd.
     */
    public void addCopy(int serialNumber, int purchasePrice, String purchaseDate){
        Copy c = new Copy(serialNumber, purchasePrice, purchaseDate);
        copies.add(c);
    }
    
    /**
     * Find o copy of a dvd by a given serial number.
     * @param serialNumber The serial number of a copy of a dvd
     */
    public Copy findCopy(int serialNumber) {
        for(Copy copy : copies){
            if(copy.getSerialNumber() == serialNumber){
                return copy;
            }
        }
        return null;
    }
    
    public int getNumberOfCopies(){
        return copies.size();
    }
}
